<#include "/ftl/front/common/_layout.html"/>
<@html title="JFinal社区 - 发布话题" description="JFinal社区 - 发布话题" sidebar_create_info="show" sidebar_md_help="show">
<link href="${baseUrl!}/static/editor_md/css/editormd.css" rel="stylesheet">
<script type="text/javascript" src="${baseUrl!}/static/editor_md/editormd.js"></script>

<div class="panel panel-default">
    <div class="panel-heading">
        <ol class="breadcrumb">
            <li><a href="${baseUrl!}/">首页</a></li>
            <li class="active">发布话题</li>
        </ol>
    </div>
    <div class="panel-body">
        <form id="create_form" action="${baseUrl!}/topic/save" method="post">
            <select name="sid" id="sid" class="form-control" style="width: 20%; margin-bottom: 5px;">
                <#list sections as section>
                    <option value="${section.id}">${section.name}</option>
                </#list>
            </select>
            <input type="text" placeholder="标题字数10字以上" id="title" name="title" class="form-control" style="margin-bottom: 5px;"/>
            <input type="text" placeholder="原文地址（原创可不写）" id="original_url" name="original_url" class="form-control" style="margin-bottom: 5px;"/>
            <div id="content" style="margin-bottom: 5px;"><textarea name="content"></textarea></div>
            <input type="button" onclick="submitForm()" value="提交" class="btn btn-primary">
        </form>
    </div>
</div>
<script type="text/javascript">
    var editor = editormd("content",{height: 500,watch:false});
    function submitForm() {
        if($("#title").val().trim().length < 10) {
            alert("标题字数10字以上");
            $("#title").focus();
        } else if(editor.getValue().trim() == "") {
            alert("内容不能为空");
        } else {
            $("#create_form").submit();
        }
    }
</script>
</@html>